import { createApp,nextTick,h,render } from 'vue'
import upgradeDialog from '@/components/basic-container/upgrade/upgradeDialog.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
let mountNode
let upgradeDialogModel = {}
let app
upgradeDialogModel.install = (option = {})=>{
  if (mountNode && !option.doubleDialog) {//确保只存在一个弹窗
    app.unmount(mountNode); 
    document.body.removeChild(mountNode)
    mountNode = null
  }
  mountNode = document.createElement('div')
  document.body.appendChild(mountNode)
  app = createApp(upgradeDialog, {
    remove: () => { 
      app.unmount(mountNode); 
      document.body.removeChild(mountNode)
      mountNode = null
     },
    ...option
  })
  app.use(ElementPlus).mount(mountNode)
}
upgradeDialogModel.remove = ()=>{
  if(mountNode){
    app.unmount(mountNode); 
    document.body.removeChild(mountNode)
    mountNode = null
  }
}
export default upgradeDialogModel
